home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / texts / hsc.lha / hsc / src_docs / features / expressions.hsc < prev    next >
Text File  |  1996-04-01  |  3KB  |  109 lines

  1. <WEBPAGE chapter="hsc - Features - " title="Expressions"
  2.     PREV=":require.html"
  3.     NEXT="spctags.html">
  4.  
  5. <P>Additionally to simple strings, you can use expressions to set the
  6. value of an attribute. Expressions <STRONG>must</STRONG> be enclosed
  7. inside "<CODE>(</CODE>" and "<CODE>)</CODE>".</P>
  8.  
  9. <P>Inside expressions, you can refer to attributes simply by their name.
  10. String constants must be enclosed inside quotes.</P>
  11.  
  12. <STRONG>Example:</STRONG><BR>
  13. <$source PRE>
  14.     <$define name:string="hugo.gif">
  15.     <IMG SRC=(name) ALT="name">
  16. </$source>
  17.  
  18. will be converted to
  19.  
  20. <$source PRE>
  21.     <IMG SRC="hugo.gif" ALT="name">
  22. </$source>
  23.  
  24.  
  25. <H1>Operators</H1>
  26.  
  27. Shortcuts:
  28. <UL>
  29. <LI><I>attr</I> stands for an attribute
  30. <LI><I>expr</I> stands for an expression
  31. </UL>
  32. <H2>Unary operators</H2>
  33. <DL>
  34.     <DT><STRONG>NOT</STRONG> <I>expr</I>
  35.     <DD>negotiate (boolean) expression
  36.     <DT><STRONG>SET</STRONG> <I>attr</I>
  37.     <DD>True, if attribute has been set during macro call
  38.     <DT><STRONG>DEFINDED</STRONG> <I>attr</I>
  39.     <DD>True, if attribute was defined with <TG>$macro</TG> or
  40.         <TG>$define</TG>
  41.     <DT><STRONG>GETENV</STRONG> <I>environment variable</I>
  42.     <DD>get value of an environment variable
  43. </DL>
  44.  
  45.  
  46. <H2>Binary operators</H2>
  47. <DL>
  48.     <DT><I>expr</I><STRONG> = </STRONG><I>expr</I>
  49.     <DD>string comparison (case insensitive)
  50.     <DT><I>expr</I><STRONG> + </STRONG><I>expr</I>
  51.     <DD>string concatenation
  52. </DL>
  53.  
  54. <STRONG>Example:</STRONG><BR>
  55. <$source PRE>
  56.     <$define name:string="hugo">
  57.     <$define here:string="here">
  58.  
  59.     <IMG SRC=(name+".gif") ALT=(name+" was "+here)>
  60.     <$if (name="hugo")>
  61.     This is hugo!
  62.     <$else>
  63.     Maybe it's sepp?
  64.     </$if>
  65.     AmigaOS version: <$insert text=(GetEnv "KickStart")>
  66. </$source>
  67.  
  68. will be converted to
  69.  
  70. <$source PRE>
  71.     <IMG SRC="hugo.gif" ALT="hugo was here">
  72.     This is hugo!
  73.     AmigaOS version: 40.63
  74. </$source>
  75.  
  76. <H2>Priorities</H2>
  77. <P><STRONG>Important:</STRONG> Different to most programming languages, <hsc>
  78. does not support priorities for different operators. Therefor, expressions
  79. are simply processed sequentialy (I'm too lazy to build a tree).</P>
  80.  
  81. <P>But you can use nested brackets within complex expressions.</P>
  82.  
  83. <H1>Boolean expressions</H1>
  84.  
  85. <P>If you pass an expression to a boolean attribute, the expression is
  86. evaluated as before. If the expression returned an empty string,
  87. the boolean attribute is set to <CODE>FALSE</CODE>. This means, that
  88. it is removed from the tag/macro-call.</P>
  89.  
  90. <P>Any none-empty string enables the attribute.</P>
  91.  
  92. <STRONG>Example:</STRONG><BR>
  93. <$source PRE>
  94.     <IMG SRC=(name) ALT="nufin" ISMAP=(name="map.gif")>
  95. </$source>
  96. will be converted to
  97. <$source PRE>
  98.     <IMG SRC="hugo.gif" ALT="nufin">
  99. </$source>
  100. if <CODE>name</CODE> has been set to <CODE>"hugo.gif"</CODE>, or to
  101. <$source PRE>
  102.     <IMG SRC="map.gif" ALT="nufin" ISMAP>
  103. </$source>
  104. <P>if <CODE>name</CODE> has been set to <CODE>"map.gif"</CODE>. Note that
  105. only the second call enables the boolean attribute <CODE>ISMAP</CODE>,
  106. while it gets stripped for the first call.</P>
  107.  
  108. </WEBPAGE>
  109.